<?php
declare (strict_types = 1);
namespace app\admin\controller;

use think\Request;
use think\Exception;
use think\exception\ValidateException;

use think\facade\Db;
use service\JsonService as Json;
use app\admin\controller\BaseController;

use app\common\model\HomeContactUs;
use app\common\model\HomeJoinConsult;

class ContactController extends BaseController
{
    /**
     * 联系我们
     */
    public function addContactUs()
    {
        $param['company_name']    = Request()->param('company_name', '');
        $param['mobile']          = Request()->param('mobile', '');
        $param['industry_demand'] = Request()->param('industry_demand', '');

        $flag = HomeContactUs::add($param);

        if(!$flag) return Json::fail();
        return Json::success();
    }

    /**
     * 联系我们列表
     */
    public function getContactUsList()
    {
        $page = Request()->param('page', 1);

        $list = HomeContactUs::getList([], 1, $page, 20, '*', 'create_time DESC');
        if(!$list) return Json::fail('暂无数据');
        return Json::success('ok', $list);
    }



    /**
     * 加盟
     */
    public function addJoinConsult()
    {
        $param['name']    = Request()->param('name', '');
        $param['mobile']  = Request()->param('mobile', '');

        $flag = HomeJoinConsult::add($param);

        if(!$flag) return Json::fail();
        return Json::success();
    }

    /**
     * 加盟咨询列表
     */
    public function getJoinConsultList()
    {
        $page = Request()->param('page', 1);

        $list = HomeJoinConsult::getList([], 1, $page, 20, '*', 'id DESC');
        if(!$list) return Json::fail('暂无数据');
        return Json::success('ok', $list);
    }
}